//
//  MYGMediaTableViewCell.swift
//  MYDoctor
//
//  Created by 小火科技 on 2024/5/24.
//

import UIKit

class MYGMediaTableViewCell: UITableViewCell {
    var type :String = ""
    var isEN:Bool = false
    var model:MYGResumeAllType? {
        didSet {
            guard let item = model else{return}
           
            var content = item.content
            if isEN == true {
                content = item.en_content
            }else {
                content = item.content
            }

            if let data = content.data(using: .utf8), let attr = try? NSAttributedString(
                data: data,
                options: [
                    .documentType: NSAttributedString.DocumentType.html,
                    .characterEncoding: String.Encoding.utf8.rawValue
                ],
                documentAttributes: nil
                    
            ) {
                
                contentLab.attributedText = attr
            }
            
           
        }
        
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        configUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // MARK: - UI
    private func configUI() {
        contentView.backgroundColor = .white
        contentView.addSubview(contentLab)
        contentLab.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(15)
            make.top.equalToSuperview().offset(17.5)
        }
     
    }
    
    private lazy var contentLab:UILabel = {
        let tw = UILabel()
        tw.text = ""
        tw.textColor = .rgba(10, 10, 10, 1)
        tw.font = .regular(16)
        tw.numberOfLines = 0
        return tw
    }()
    
}
